"""
@-*- coding: utf-8 -*-
@ python: 3.12.3
@ 创建者: JacksonCode
@ 创建时间: 2024/12/20
"""

import numpy as np

array = np.array([[1, 2, 3], [4, 5, 6]])
print(array)

print(np.sum(array))

print(np.sum(array, axis=0))  # 第一个轴  [5 7 9]   上下

print(np.sum(array, axis=1))  # 一行  [ 6 15]

print(array.sum())
print(array.sum(axis=0))  # [5 7 9]
print(array.sum(axis=1))  # [ 6 15]

print(np.prod(array))  # 720
print(array.prod())  # 720

print(np.prod(array, axis=0))
print(np.prod(array, axis=1))
print(array.prod(axis=0))  # [ 4 10 18]
print(array.prod(axis=1))  # [  6 120]

print(array.min())
print(array.min(axis=0))
print(array.min(axis=1))

print(array.max())
print(array.max(axis=0))
print(array.max(axis=1))

print(array.argmin())  # index
print(array.argmin(axis=0))  #
print(array.argmin(axis=1))  #

print(array.argmax())
print(array.argmax(axis=0))
print(array.argmax(axis=1))

print(array.mean())  # 均值   3.5
print(array.mean(axis=0))
print(array.mean(axis=1))

print(array.std())  # 标注差 1.707825127659933
print(array.std(axis=0))  # [1.5 1.5 1.5]
print(array.std(axis=1))  # [0.81649658 0.81649658]

print(array.var())  # 方差   2.9166666666666665
print(array.var(axis=0))  # [2.25 2.25 2.25]
print(array.var(axis=1))  # [0.66666667 0.66666667]

print(array)

print(array.clip(2, 4))  # 限制   <  -> 2      >   ->   4

array2 = np.array([1.2, 3.5, 5.6, 7.8])
print(array2.round())  # 四舍五入  [1. 4. 6. 8.]

print(array2.round(decimals=1))  # 精度 [1.2 3.5 5.6 7.8]
